﻿using System;
using System.Reflection;
using System.Collections.Generic;
using System.Text;

namespace ORM.Annotations
{
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
    public class EntityTable : Attribute
    {
        /// <summary>
        /// Table name
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// Title name
        /// </summary>
        public string Title { get; set; }

        /// <summary>
        /// Default false
        /// </summary>
        public bool IsCache { get; set; }

        /// <summary>
        /// Default false
        /// </summary>
        public bool IsDictionary { get; set; }

        public EntityTable()
        {
            this.IsCache = false;
            this.IsDictionary = false;
        }

        public EntityTable(string tableName)
            : this()
        {
            this.Name = tableName;
        }

        public override string ToString()
        {
            return this.Name + "\t" + this.Title;
        }
    }

    [AttributeUsage(AttributeTargets.Property)]
    public class EntityFeild : Attribute
    {
        /// <summary>
        /// Default false
        /// </summary>
        public bool Id { get; set; }

        /// <summary>
        /// Table name
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// Title name
        /// </summary>
        public string Title { get; set; }

        public PropertyInfo FeildRefInfo { get; set; }

        public EntityFeild()
        {
            this.Id = false;
        }

        public EntityFeild(string columnName)
            : this()
        {
            this.Name = columnName;
        }

        public override string ToString()
        {
            return this.Name + "\t" + this.Title;
        }
    }

    public class ORMAnalyzerException : Exception
    {
        public ORMAnalyzerException(string message)
            : base(message)
        { }

        public ORMAnalyzerException(string message, Exception exception)
            : base(message, exception)
        { }
    }
}
